package com.renli.controller;

import com.renli.bean.ResultJson;
import com.renli.pojo.Resume;
import com.renli.service.ArchivesService;
import com.renli.service.RecruitService;
import com.renli.vo.ArchivesVo;
import com.renli.vo.DepEducationVo;
import com.renli.vo.EducationCountVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api(value = "data", tags = "数据分析")
@RestController
@RequestMapping("/data")
public class DataAnalysisController {

    @Autowired
    private ArchivesService archivesService;
    @Autowired
    private RecruitService recruitService;

    /**
     * 查询职员明细
     * 明细列表
     *
     * @param map
     * @return
     */
    @ApiOperation(value = "查询职员明细,明细列表",notes = "查询员工的key：" +
            "depId：部门id；" +
            "realName：员工姓名；" +
            "state：档案状态（0试用期，1正式员工，2离职，3已删除，4实习）" +
            "startDate：建档时间开始；" +
            "endDate：建档时间结束;" +
            "currentPage:当前页（默认1）；" +
            "pageSize：每页显示行数（默认6）；",httpMethod = "post",response = ResultJson.class)
    @RequestMapping(value = "/findArchives", method = RequestMethod.POST)
    public ResultJson<List<ArchivesVo>> findArchives(@RequestBody(required = false) @ApiParam(name = "map", value = "查询条件") Map<String, Object> map) {

        return archivesService.find(map);

//        ResultJson<List<ArchivesVo>> resultJson = new ResultJson<>();
//
//        List<ArchivesVo> list = new ArrayList<>();
//        list.add(new ArchivesVo());
//        list.add(new ArchivesVo());
//        list.add(new ArchivesVo());
//        resultJson.setSuccess("查询成功", list);
//    return resultJson;
    }

    /**
     * 职员数据综合报表
     */
    @ApiOperation("职员数据综合报表")
    @RequestMapping(value = "/findEducationCont", method = RequestMethod.POST)
    public ResultJson<List<EducationCountVo>> findEducationCont(@RequestBody(required = false) @ApiParam(name = "map", value = "分页信息，默认1，6") Map<String, Integer> map) {
        ResultJson<List<EducationCountVo>> resultJson = new ResultJson<>();
        List<EducationCountVo> list = new ArrayList<>();

        list.add(new EducationCountVo());
        list.add(new EducationCountVo());
        list.add(new EducationCountVo());

        resultJson.setSuccess("ss", list);
        return resultJson;
    }

    //
    @RequestMapping(value = "/findEducationContByYear", method = RequestMethod.POST)
    public ResultJson<List<DepEducationVo>> findEducationContByYear(@RequestBody @ApiParam(name = "map", value = "分页信息，默认1 6 ,年份（year）") Map<String, Integer> map) {
        ResultJson<List<DepEducationVo>> resultJson = new ResultJson<>();
        List<DepEducationVo> list = new ArrayList<>();

        list.add(new DepEducationVo());
        list.add(new DepEducationVo());
        list.add(new DepEducationVo());

        resultJson.setSuccess("ss", list);
        return resultJson;

    }

    //异动统计分析
    @RequestMapping(value = "/move", method = RequestMethod.POST)
    public ResultJson move(@RequestBody(required = false) @ApiParam(name = "map", value = "年份") Map<String, String> map) {

        ResultJson resultJson = new ResultJson();

        return resultJson;
    }


    //公司各种体系结构分析
    @RequestMapping(value = "/resumed", method = RequestMethod.POST)
    public ResultJson<List<Resume>> resumed(@RequestBody(required = false) @ApiParam(name = "map", value = "员工姓名和分页信息") Map<String, Object> map) {
        ResultJson<List<Resume>> r = new ResultJson<>();
        List<Resume> list = new ArrayList<>();
        list.add(new Resume());
        list.add(new Resume());
        list.add(new Resume());
        r.setSuccess("", list);
        return r;
    }
    /**
     * 储备人才统计表
     */
    @ApiOperation(value = "储备人才统计表",httpMethod = "post",notes = "realName:员工姓名",response = ResultJson.class,produces = "realName,gender(0男1女),phone,major,education,graduation,workDate,resumeState（-1没有应聘过，-2应聘过）")
    @RequestMapping(value = "/talentReserve",method = RequestMethod.POST)
    public ResultJson<List<Map<String,Object>>> talentReserve(@RequestBody(required = false) @ApiParam(name = "map",value = "员工姓名：realName,当前页：currentPage,页面行数：pageSize") Map<String,Object> map){
        return recruitService.find(map);
    }

}
